//
//  MainCollectionViewCell.m
//  Funny
//
//  Created by dllo on 15/10/29.
//  Copyright © 2015年 King. All rights reserved.
//

#import "MainCollectionViewCell.h"

@implementation MainCollectionViewCell

-(instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        self.headerImg = [[UIImageView alloc]init];
        [self.contentView addSubview:self.headerImg];
        self.headerImg.layer.masksToBounds = YES;
        self.headerImg.layer.cornerRadius = 30;
        
        self.name = [[UILabel alloc]init];
        self.name.textColor = [UIColor colorWithRed:0 green:220.0 / 256.0 blue:220.0 / 256.0 alpha:1.0];
        [self.contentView addSubview:self.name];
        self.name.font = [UIFont systemFontOfSize:14.0];
        
        self.content = [[UILabel alloc]init];
        self.content.textColor = [UIColor whiteColor];
        self.content.numberOfLines = 3;
        self.content.font = [UIFont systemFontOfSize:14];
        [self.contentView addSubview:self.content];
    }
    return self;
}

// set方法赋值

-(void)setModel:(MainCityModel *)model
{
    [self.headerImg sd_setImageWithURL:[NSURL URLWithString:model.headpic] placeholderImage:[UIImage imageNamed:@"default_icon@2x.png"]];
    self.name.text = model.nickname;
    self.content.text = model.content;
}

-(void)layoutSubviews
{
    [super layoutSubviews];
    WeakSelf(weakSelf);
    [self.headerImg mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(weakSelf.contentView).with.offset(15);
        make.top.equalTo(weakSelf.contentView).with.offset(40);
        make.size.mas_equalTo(CGSizeMake(60, 60));
    }];
    
    [self.name mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(weakSelf.headerImg.mas_right).with.offset(10);
        make.top.equalTo(weakSelf.contentView).with.offset(30);
        make.right.equalTo(weakSelf.contentView).with.offset(15);
        make.height.equalTo(@20);
    }];
    
    [self.content mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(weakSelf.headerImg.mas_right).with.offset(10);
        make.top.equalTo(weakSelf.name).with.offset(20);
        make.size.mas_equalTo(CGSizeMake(270 * W, 60));
    }];
}

@end
